package org.kzwl.book.controller.app;

import io.swagger.annotations.ApiOperation;
import org.kzwl.service.app.impl.MinIoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class PathController {


    @Autowired
    MinIoService minIoService;

    @GetMapping("/getFilePath")
    public String getFilePath(String pathName)
    {
        return minIoService.getFilePath(pathName);
    }


    @ApiOperation(value = "上传文件")
    @PostMapping(value = "/upload")
    public String upload(@RequestParam("file") MultipartFile file) {
        String fileUrl = minIoService.upload(file);
        return "文件下载地址：" + fileUrl;
    }
}
